<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Welcome extends CI_Controller {

	function __construct()
	{
		parent::__construct();
		session_start();	
	}

	function index()
	{
		$data['title'] = "Codeigniter Project";
		$data['main'] = 'public_home';
		$this->load->vars($data);
		$this->load->view('template');
	}
	
	function login()
	{
		$this->load->library('encrypt');
		if ($this->input->post('username'))
		{
			$u = $this->input->post('username');
			$pw = $this->input->post('password');
			$row = $this->Users_model->verifyUser($u,$pw);
			if (count($row))
			{
				$_SESSION['userid'] = $row['id'];
				redirect('admin/dashboard','refresh');
			}
			else
			{
				redirect('welcome/login','refresh');
			}
		}
		else
		{
			$data['title'] = "Codeigniter Project Login";
		  	$data['main'] = 'login';
		  	$this->load->vars($data);
		  	$this->load->view('template');
		}
	}
	
	
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */